<template>
	<div class="alert">
		<div class="alert-box">
			<h2>退费详情</h2>
            <i class="el-icon-close close" @click="cancel"></i>
           	<el-form ref="form-class" label-width="100px" class="add-class-form" label-position="left">
                <el-form-item class="item" label="学生姓名">
                    <el-input v-model="studentName" disabled></el-input>
                </el-form-item>
                <el-form-item class="item" label="退费类型">
                    <el-select v-model="type" placeholder="请选择退费类型" class="select-block">
                        <el-option :label="v" :value="v" v-for="v in typeList"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item class="item" label="退费账号">
                    <el-input v-model="number"></el-input>
                </el-form-item>
                <el-form-item class="item" label="退费金额">
                    <el-input v-model="money"></el-input>
                </el-form-item>
                <el-form-item class="item" label="退费描述">
                    <el-input type="textarea" v-model="account" :rows="4"></el-input>
                </el-form-item>
				<el-button type="info" class="submit" @click="submit">提交</el-button>
            </el-form>

		</div>
	</div>
</template>

<script type="text/javascript">

    import qs from 'qs'
    import LoadingComponent from 'components/loading'
    export default {
        components: { LoadingComponent },
        props: ['params'],
        data () {
            return {
                isLoading:false,
                studentName: '',
                money: '',
                account: '',
                number: '',
                type: '',

                typeList: ['支付宝', '微信', '银行卡']
            }
        },
        created () {
            this.studentName = this.params.row.zwm;

            console.log(this.params)
        },
        methods: {
            submit () {
                if (!this.money) {
                    this.$message.warning('请输入退费金额');
                    return;
                }else if(!this.type){
                    this.$message.warning('请选择退费类型');
                    return;
                }else if(!this.number){
                    this.$message.warning('请输入退费账号');
                    return;
                }
								var params3 = qs.stringify({
									xsid: this.params.row.xsid,
									tfje: this.money,
									tfyy: this.account,
									tfsklx: this.type,
									tfzh: this.number
								});
                this.axios.post(this.$store.state.api + 'xstf/add', params3).then( res => {
                    console.log(res)
                    this.$emit('close',{type:'free',cancel:false})
                    // this.$emit('close',{type:'add',cancel:false})
                }).catch( res => {
                    console.log(res)
                    this.$message.warning("添加数据失败")
                    // this.$emit('close','add')
                })
            },
            cancel () {
               this.$emit('close',{type:'free',cancel:true})
            }
        }
    }
</script>

<style lang="less" scoped>

    .alert-box {
        width: 500px;
    }
	h2 {
		line-height: 30px;
	}

    .item {
        width: 300px;
        margin:20px auto;
    }
	.submit {
		width: 120px;
	}
</style>
